package com.augurit.wf.app.document.utils;

import java.util.ArrayList;
import java.util.List;

//import com.augurit.astat.metadata.web.measure.form.MetaMeasureCategoryForm;
//import com.augurit.astat.metadata.web.measure.form.MetaMeasureDictionaryForm;
import com.augurit.wf.app.document.web.form.DocCategoryForm;
import com.augurit.wf.app.document.web.form.DocumentForm;
/**
 * 树节点基础类
 * 
 *
 */
public class TreeUtil {

	/**
	 * 将指标分类列表转化为树节点列表
	 * @param list 指标分类列表
	 * @return 树节点列表
	 * */
/*	public static List<TreeNode> convertCategoryForms2TreeNodes(List<MetaMeasureCategoryForm> list){
		List<TreeNode> nodes = null;
		if(list != null && list.size()>0){
			nodes = new ArrayList<TreeNode>();
			for(MetaMeasureCategoryForm form:list){
				nodes.add(convertCategoryForm2TreeNode(form));
			}
		}
		return nodes;
	}*/
	
	public static List<DocTreeNode> convertDocumentForms2TreeNodes(List<DocumentForm> list){
		List<DocTreeNode> nodes = null;
		if(list != null && list.size()>0){
			nodes = new ArrayList<DocTreeNode>();
			for(DocumentForm form:list){
				nodes.add(convertDocumentForm2TreeNode(form));
			}
		}
		return nodes;
		
	}
	
	public static DocTreeNode convertDocumentForm2TreeNode(DocumentForm form){
		DocTreeNode node = null;
		if(form!=null){
			node =new DocTreeNode();
			node.setEditable(false);
			node.setId("DOC-"+form.getId());
			node.setDocId(form.getId());
			node.setDocName(form.getName());
			node.setDraggable(true);
			node.setExpandable(false);
			node.setIconCls("file");
			node.setLeaf(true);
			node.setPartyType("DOC");
			node.setPid(form.getCid());
			node.setText(form.getName());
		}
		return node;
		
	}
	
	
	public static List<DocTreeNode> convertDocCategoryForms2TreeNodes(List<DocCategoryForm> list){
		List<DocTreeNode> nodes = null;
		if(list != null && list.size()>0){
			nodes = new ArrayList<DocTreeNode>();
			for(DocCategoryForm form:list){
				nodes.add(convertDocCategoryForm2TreeNode(form));
			}
		}
		return nodes;
	}
	
	public static DocTreeNode convertDocCategoryForm2TreeNode(DocCategoryForm form){
		DocTreeNode node = null;
		if(form != null){
			
			node = new DocTreeNode();
			node.setEditable(true);
			node.setId("DIR-"+form.getId());
			node.setDirId(form.getId());
			node.setDirName(form.getName());
			node.setDraggable(false);//所有的目录都不允许拖放，如果该目录有父目录的时候，允许可以拖放,如何实现？
			node.setExpandable(true);//
			node.setIconCls("folder");
			node.setLeaf(false);
			node.setPartyType("DIR");
			node.setText(form.getName());
			node.setPid(form.getPid());
		
		}
		return node;
	}	
	
		
	/**
	 * 将指标分类form对象转化为树节点
	 * @param list 指标分类form对象
	 * @return 树节点
	 * */
/*	public static TreeNode convertCategoryForm2TreeNode(MetaMeasureCategoryForm form){
		TreeNode node = null;
		if(form != null){
			node = new TreeNode();
			node.setId("cg-"+form.getId());
			node.setText(form.getName());
			node.setLeaf(false);
			node.setCstype("measureCategory");
			node.setHasChildren(true);
		}
		return node;
	}*/	
	/**
	 * 将指标分类列表转化为树节点列表
	 * @param list 指标分类列表
	 * @return 树节点列表
	 * */
	/*public static List<TreeNode> convertMeasureDictionary2TreeNodes(List<MetaMeasureDictionaryForm> list){
		List<TreeNode> nodes = null;
		if(list != null && list.size()>0){
			nodes = new ArrayList<TreeNode>();
			for(MetaMeasureDictionaryForm form:list){
				nodes.add(convertMeasureDictionary2TreeNode(form));
			}
		}
		return nodes;
	}*/
	/**
	 * 将指标分类form对象转化为树节点
	 * @param list 指标分类form对象
	 * @return 树节点
	 * */
	/*public static TreeNode convertMeasureDictionary2TreeNode(MetaMeasureDictionaryForm form){
		TreeNode node = null;
		if(form != null){
			node = new TreeNode();
			node.setId("ms-"+form.getId());
			node.setText(form.getName());
			node.setLeaf(true);
			node.setCstype("measure");
			node.setHasChildren(false);
			node.setIconCls("icon-lightning");
		}
		return node;
	}*/
}
